﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace THenu.TinyHourseLib.EventAndDelegate
{
    public class WeakDelegate
    {
        private WeakReference m_TargetRef;
        private MethodInfo m_Method;
        public WeakDelegate(Delegate dele)
        {
            m_TargetRef = new WeakReference(dele.Target);
            m_Method = dele.Method;
        }
        public object Invoke(params object[] args)
        {
            object target = m_TargetRef.Target;
            if (target != null)
                return m_Method.Invoke(target, args);
            return null;
        }

        internal static WeakDelegate Combine(WeakDelegate m_WeakEvent, EventHandler value)
        {
            throw new NotImplementedException();
        }

        internal static WeakDelegate Remove(WeakDelegate m_WeakEvent, EventHandler value)
        {
            throw new NotImplementedException();
        }
    }
}
